//
//  UserModel.m
//  EverydayNews
//
//  Created by 李沛池 on 2017/7/22.
//  Copyright © 2017年 Godlike. All rights reserved.
//

#import "UserModel.h"

@implementation UserModel

singleton_implementation(UserModel);

/*
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initData];
    }
    return self;
}

- (void)initData
{
    NSString *userID = [DefaultSystemPlist objectForKey:@"userID"];
    if (userID.length > 0) {
        _userID = userID;
    }
    NSString *userIcon = [DefaultSystemPlist objectForKey:@"userIcon"];
    if (userIcon.length > 0) {
        _userIcon = userIcon;
    }
    NSString *userNickName = [DefaultSystemPlist objectForKey:@"userNickName"];
    if (userNickName.length > 0) {
        _userNickName = userNickName;
    }
}
 */

//保存用户信息
+ (void)saveUserData:(UMSocialUserInfoResponse *)resp
{
    UserModel *model = [UserModel sharedUserModel];
    model.userID = resp.uid;
    model.userIcon = resp.iconurl;
    model.userNickName = resp.name;
}

//清理用户信息
+ (void)clearUserData
{
    UserModel *model = [UserModel sharedUserModel];
    model.userID = @"";
    model.userIcon = @"";
    model.userNickName = @"";
}

//返回是否已登录
+ (BOOL)isLogin
{
    if ([UserModel sharedUserModel].userID.length > 0) {
        return YES;
    }
    return NO;
}


- (void)setUserID:(NSString *)userID
{
    [DefaultSystemPlist setObject:userID forKey:@"userID"];
}

- (void)setUserIcon:(NSString *)userIcon
{
    [DefaultSystemPlist setObject:userIcon forKey:@"userIcon"];
}

- (void)setUserNickName:(NSString *)userNickName
{
    [DefaultSystemPlist setObject:userNickName forKey:@"userNickName"];
}

- (NSString *)userID
{
    return [DefaultSystemPlist objectForKey:@"userID"];
}

- (NSString *)userIcon
{
    return [DefaultSystemPlist objectForKey:@"userIcon"];
}

- (NSString *)userNickName
{
    return [DefaultSystemPlist objectForKey:@"userNickName"];
}


@end
